var borrowing;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_borrowing) {
    if (_borrowing == undefined || !(_borrowing instanceof com.jf.crawl.model.InterbankBorrowing)) {
        throw new java.lang.Exception("borrowing 对象为空");
    }
    log.info("borrowing {}", _borrowing)
    borrowing = _borrowing;
}

function crawler() {
    var html = Get("http://www.chinamoney.com.cn/fe/static/html/column/marketdata/dailyexpress/daily/creditlend/creditLendDaily.html");
    var doc = Jsoup.parse(html);
    var trs = doc.select("table.market-new-text").get(1).select("tr");
    if (trs.size() > 4) {
        //忽略前2行
        for (var i = 2; i < trs.size() - 2; i++) {
            var tds = trs.get(i).select("td");
            if (tds.size() == 9) {
                var name = tds.get(0).text();
                var price = tds.get(3).text();
                if (name == "IBO001") {
                    borrowing.setIb0001(commonUtil.string2Decimal(price));
                } else if (name == "IBO007") {
                    borrowing.setIb0007(commonUtil.string2Decimal(price));
                } else if (name == "IBO014") {
                    borrowing.setIb0014(commonUtil.string2Decimal(price));
                } else if (name == "IBO021") {
                    borrowing.setIb0021(commonUtil.string2Decimal(price));
                } else if (name == "IBO1M") {
                    borrowing.setIb01Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO2M") {
                    borrowing.setIb02Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO3M") {
                    borrowing.setIb03Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO4M") {
                    borrowing.setIb04Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO6M") {
                    borrowing.setIb06Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO9M") {
                    borrowing.setIb09Month(commonUtil.string2Decimal(price));
                } else if (name == "IBO1Y") {
                    borrowing.setIb01Year(commonUtil.string2Decimal(price));
                }
            }
        }
    }
    return true;
}